package com.songshuai.webapi.permission.common.enumerations;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public enum EduContactType {
    Phone(0, "联系号码"),
    Email(1, "邮箱"),
    Telephone(2, "座机"),
    Qq(3, "QQ"),
    Skype(4, "Skype"),
    Weixin(8,"微信");
    private int code;
    private String msg;

    EduContactType(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return EduContactType.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return EduContactType.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            log.error("undefined error code: {}", define);
            return "";
        }
    }

    public static String getMsg(int code){
        for(EduContactType err : EduContactType.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "errorCode not defined ";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
